package com.itheima.web.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@Controller
@RequestMapping("/user")
//@ResponseBody
@RestController
public class UserController {

    @Autowired
    private UserService userService;


     //查询所有
    @RequestMapping("/findAll")
    public List<User> findAll(){
        System.out.println("test");
        return userService.findAll();
    }


     //根据id查询
    @RequestMapping("/findById")
    public User findById(Integer id){
        return userService.findById(id);
    }


     // 更新
    @RequestMapping("/updateUser")
    public void updateUser(@RequestBody User user){
        System.out.println(user);
        userService.updateUser(user);
    }
}
